Previous Book Contents Book Index Next

Inside Macintosh: AppleScript Language Guide / Part 2 - AppleScript Language Reference
Chapter 5 - Objects and References / Reference Forms


Relative

The Relative reference form specifies an object or a location by describing its position in relation to another object, known as the base, in the same container.

SYNTAX
[ className ] ( before | [in] front of ) baseReference 
[ className ] ( after | [in] back of | behind ) baseReference    
where

className is the class identifier of the specified object. If you leave out this parameter, AppleScript assumes you want an insertion point.

baseReference is a reference to the base object.

The before and in front of forms, which are equivalent, refer to the object immediately preceding the base object. The after, in back of, and behind forms are equivalent and refer to the object immediately after the base.

EXAMPLES
The following references specify the word immediately before the first figure.

word before figure 1
word in front of figure 1
The following examples specify the insertion point immediately before the tenth paragraph.

before paragraph 10
in front of paragraph 10
The following example contains three references. The first two are Index references that specify the front document and the first word. The third
is a Relative reference that specifies the insertion point before the tenth paragraph. The command moves the first word to the insertion point
before the tenth paragraph.

tell front document of application "Scriptable Text Editor"   move word 1 to before paragraph 10
end tell
NOTES
You can specify only a single object with the Relative form. You can use the form to specify an object that is either before or after the base object.

If it is possible for the specified object to contain the base object (as in the expression paragraph before word 99), the reference does not specify
the container but instead specifies the object immediately before or after the container of the base object. For example, the expression paragraph before word 99 specifies the paragraph immediately before the paragraph containing the ninety-ninth word.

All applications allow you to specify a base object belonging to the same
class as the desired object (such as window in back of window "Big"). Not all allow you to specify a base of a different object class (such as word before figure 1). The possible base classes for a particular class are up
to each application.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
13 JUL 1996